package models

import "gorm.io/gorm"

type Article struct {
	gorm.Model
	Name   string  `gorm:"type:varchar(20)"`
	Author string  `gorm:"type:varchar(20)"`
	Price  float64 `gorm:"type:decimal(10,2)"`
}

func (a *Article) ArticleAdd(db *gorm.DB) error {
	return db.Debug().Create(a).Error
}

func (a *Article) ArticleUpdate(db *gorm.DB) error {
	return db.Debug().Updates(a).Error
}

func (a *Article) FindArticle(db *gorm.DB, id int64) error {
	return db.Debug().Where("id=?", id).Find(a).Error
}
